C++ Code

This example uses the C/C++ Platform in a simple way. It demonstrates how to test a simple SUT implemented as a class in C++.

Open the file Help|Examples|03 Test Execution Platforms|03 C++ Code. Select Execution|Platform Configuration to open the Platform Configuration dialog.

C++ Code example settings

The source files LightsControlData.cpp and LightsControlModule.cpp are tested. The interface is already imported. Select View|Declaration Editor to open the Declaration Editor to display the imported signals.

If you apply changes to the signals in the source code, you must re-import the interface. Open the Platform Configuration dialog and select C/C++ Platform. Press the Analyze Sources button and then Import Interface. In the Import Interface dialog press the Default All button and then OK.

All channels and parameters will be imported into the TPT namespace data. data is the name of the class instance created in the Custom Wrapper Code section.

Custom wrapper code section

The C/C++ Platform can handle classes and instances only by importing them into variable names of the form [instance_name]::variable_name. There is currently no direct connection between namespaces in the code and TPT's own namespaces.

Add the [instance_name] to the Using namespaces field in the step list, to use the short variable names in the steps.

Declaration Editor showing the signals, and the step list belonging to test case "switch off to on"

Whenever you change the source code, compile the code again. Open the Platform Configuration dialog, and select C/C++ Platform. Click Generate & Compile.

Related topics